package pilgun.Multithread.ThreadPool;

import java.util.ArrayDeque;
import java.util.List;
import java.util.Queue;



class RunLolaRun implements Runnable{
	private static Integer num = 0;
	private int id;
	public  RunLolaRun (){
		synchronized(num){
			id = num++;
		}
	}
	public void run(){
		System.out.println(Thread.currentThread().getName()+ " started "+id);
		try {
			Thread.sleep(2000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println(Thread.currentThread().getName()+ " ended");
	}
}

public class ThreadPoolTry {
	private static int POOL_SIZE = 5;
	private static int TASK_NUM = 8;
	public static void main(String[] args) {
		ThreadPool tp = new ThreadPool(POOL_SIZE);
		for (int i=0;i<TASK_NUM;i++){
			tp.submit(new RunLolaRun());
		}
		tp.shutdown();
	}
}
